//
//  HJStatus.swift
//  WeiBo
//
//  Created by 韩俊 on 15/12/9.
//  Copyright © 2015年 HanJun. All rights reserved.
//

import UIKit

class HJStatus: NSObject {
    
    var id: Int64 = 0
    //微博信息内容
    var text :String?
    
    var user :HJUser?
    
    // 微博的创建时间
    var created_at: String?
    // 来自
    var source: String?
    // 转发
    var reposts_count: Int = 0
    // 评论数
    var comments_count: Int = 0
    // 表态数
    var attitudes_count: Int = 0
    // 转发微博的内容
    var retweeted_status: HJStatus?
    
    // 当前微博的图片
    var pic_urls:[HJStatusPictureInfo]?
    
    init(dic: [String:AnyObject]){
        
        super.init()
        
        setValuesForKeysWithDictionary(dic)
    }
    
//    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
            
            if let dic = value as? [String:AnyObject] {
                
                user = HJUser(dic:dic)
            }
        }else if key == "retweeted_status" {
            
            if let dic = value as? [String:AnyObject] {
                
                retweeted_status = HJStatus(dic: dic)
            }
        }else if key == "pic_urls"{
            
            if let array = value as? [[String:AnyObject]]{
                
                var tempArray = [HJStatusPictureInfo]()
                
                for dic in array {
                    
                    tempArray.append(HJStatusPictureInfo(dic: dic))
                    
                }
                pic_urls = tempArray
            }
        
        }else{
            
            super.setValue(value, forKey: key)
        }
        
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    
    
    override var description:String {
        
        let keys = ["text","retweeted_status"]
        return dictionaryWithValuesForKeys(keys).description
    }
}
